<template>
  <iframe :src="iframeUrl" scrolling="no" width="100%" :height="iframeHeight" frameborder="0" />
</template>
<script>

export default {
  name: 'Interior',
  props: {
    selectList: {
      type: Array,
      default: () => [],
      required: true
    },
    single: {
      type: String
    },
    checkMaterials: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      iframeHeight: 400
    }
  },
  computed: {
    iframeUrl() {
      const single = this.single ? `?single=${this.single}` : ''
      const checkMaterials = `${this.single ? '&' : '?'}checkMaterials=${this.checkMaterials}`
      return `${process.env.VUE_APP_ZHONGRUAN_URL}interiorVerify${single}${checkMaterials}`
    }
  },
  created() {
    window.sessionStorage.setItem('prjInfos', JSON.stringify(this.selectList))
    // 判断是物资还是清单
    window.addEventListener('message', (event) => {
      const base_url = ''
      if (event.origin === base_url) {
        return
      }
      this.iframeHeight = this.checkMaterials ? event.data.height : 400
    })
  }

}
</script>

<style scoped lang='scss'></style>
